/**
 * 2015年9月17日上午8:59:42
 * RoadLostSched.javaRoadLostSched
 */
package com.service.scheduler.sched;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerKey;

import com.service.cache.CacheManager;
import com.service.other.Logger;
import com.service.scheduler.job.GarbageDataSyncJob;
import com.service.scheduler.server.SchedulerCreator;

/**
 * 2015年9月17日上午8:59:42
 *
 * 张
 * 路段未去报警
 * 
 */
public class GarbageDataSyncSched {

	private Scheduler garbageDataSyncSched;
	
	public void init() {
		try {
			garbageDataSyncSched = SchedulerCreator.createScheduler(GarbageDataSyncSched.class.getSimpleName(), 1, Trigger.DEFAULT_PRIORITY);
			initGarbageData();
			CacheManager.instance().schedMap.put(garbageDataSyncSched.getSchedulerName(), garbageDataSyncSched);
		} catch (SchedulerException e) {
			Logger.err(e);
		}
	}

	/**
	 * @throws SchedulerException 
	 * 
	 */
	private void initGarbageData() throws SchedulerException {
		JobKey jobKey = SchedulerCreator.createJobKey("garbageDataSync","com.service.cache");
		TriggerKey triggerKey = SchedulerCreator.createTriggerKey("garbageDataSync", "com.service.cache");
		//String cronExpr = "0 0 0 * * ?";
		String expr = SchedulerCreator.createMinuteExpr(5);
		JobDetail jd = SchedulerCreator.createJob(jobKey, GarbageDataSyncJob.class);
		CronTrigger ct = SchedulerCreator.createCronTrigger(triggerKey, expr);
		garbageDataSyncSched.scheduleJob(jd, ct);
	}
	
}
